package com.JL.engine.model;

import com.JL.engine.components.DimensionComponent;
import com.JL.engine.components.PositionComponent;

import java.awt.*;
import java.awt.geom.Point2D;
import java.util.HashMap;
import java.util.Map;

public class InitData {

    private PositionComponent point = new PositionComponent();

    private String name;

    private DimensionComponent dimension = new DimensionComponent();

    private final Map<String,Object> options=new HashMap<>();

    public void putOption(String key,Object value){
        this.options.put(key, value);
    }

    public <T> T getOption(String key){
        return (T) this.options.get(key);
    }
    public int get(String key,int defaultValue){
        Object value =this.options.get(key);
        if (value instanceof Number){
            return ((Number) value).intValue();
        }
        return defaultValue;
    }
    public double get(String key,double defaultValue){
        Object value =this.options.get(key);
        if (value instanceof Number){
            return ((Number) value).doubleValue();
        }
        return defaultValue;
    }
    public String get(String key,String defaultValue){
        Object value =this.options.get(key);
        if (value instanceof Number){
            return value.toString();
        }
        return defaultValue;
    }

    public Point2D getPoint(){
        return point.getPosition();
    }

    public void setPoint(Point2D point){
        this.point.setPosition(point);
    }

    public void setPosition(double x, double y){
        this.point.setPosition(x,y);
    }

    public void  setSize(int width,int height){
        this.dimension.setSize(width,height);
    }

    public String getName(){
        return name;
    }

    public void setName(String name){
        this.name=name;
    }

    public Dimension getDimension(){
        return dimension.getDimension();
    }
    public void setDimension(Dimension dimension){
        this.dimension.setSize(dimension);
    }
}